﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.Helper;

using LineStickerDwonload.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LineStickerDwonload.Linehelper
{
    internal class ApngToGif
    {
        public static string FfmpegPath = StaticValue.BinPath + "ffmpeg.exe";

        /// <summary>
        /// 转换方法
        /// </summary>
        /// <param name="ApngPath"></param>
        /// <returns></returns>
        public static string Convert(string ApngPath)
        {
            return Convert(ApngPath, FileNameHelper.CreateFileNameWithExtension(ApngPath, ".gif"));
        }

        /// <summary>
        /// 转换方法
        /// </summary>
        /// <param name="ApngPath"></param>
        /// <param name="GifPath"></param>
        /// <returns></returns>
        public static string Convert(string ApngPath, string GifPath)
        {
            if (ApngPath == "" || !FileHelper.FileExits(ApngPath))
            {
                PrintLog.E("未选择文件。");
                return "未选择文件。";
            }
            string ConvertApngToGif = $"  -i \"{ApngPath}\" -q 10   \"{GifPath}\"  ";
            Console.WriteLine(ConvertApngToGif);
            Console.WriteLine(new ProcessHelper().RunCmdReadAll(FfmpegPath, "", ConvertApngToGif));
            return "";
        }
    }
}